package custom_sorting;

import java.util.ArrayList;
import java.util.Collections;

public class Test {

	public static void main(String[] args) {
		
		ArrayList<ValueObject> volist = new ArrayList<ValueObject>();
		ValueObject ob1 = new ValueObject("C", 35);
		ValueObject ob2 = new ValueObject("D", 40);
		ValueObject ob3 = new ValueObject("A", 24);
		ValueObject ob4 = new ValueObject("B", 20);
		ValueObject ob5 = new ValueObject("E", 20);
		volist.add(ob1);
		volist.add(ob2);
		volist.add(ob3);
		volist.add(ob4);
		volist.add(ob5);
		System.out.println("Sorting using Comparable ");
		Collections.sort(volist);

		for (ValueObject tmp : volist) {
			System.out.println(tmp.getName() + ":" + tmp.getJntu_no());
		}

		Collections.sort(volist, ob1.jc);
		System.out.println("After sorting on Jntu_no using Comparator");
		for (ValueObject tmp2 : volist) {
			System.out.println(tmp2.getName() + ":" + tmp2.getJntu_no());
		}

	}  

}
